﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Publisher_WS
{
    [Serializable]
    public class SachTrongGio
    {
        

        int maSach;

        public int MaSach
        {
            get { return maSach; }
            set { maSach = value; }
        }
        int soLuong;

        public int SoLuong
        {
            get { return soLuong; }
            set { soLuong = value; }
        }

        decimal donGia;

        public decimal DonGia
        {
            get { return donGia; }
            set { donGia = value; }
        }

        public SachTrongGio(int maSach, int soLuong)
        {
            this.maSach = maSach;
            this.soLuong = soLuong;
            try
            {
                   Sach sach =  DataProvider.entities
                                      .Saches
                                      .Where(s => (s.MaSach == maSach))
                                      .Single();
                   this.donGia = (decimal)sach.GiaSach;          
            }
            catch
            {
                donGia = -1;                
            }
        }
    }
}